package com.exam.api.modules.system.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 角色表实体
 *
 * @author bcheng
 */
@Schema(description = "角色表")
@Data
@TableName(value = "tbl_role", autoResultMap = true)
public class TblRole implements Serializable {
    /**
     * 角色ID
     */
    @TableId(value = "role_id", type = IdType.ASSIGN_ID)
    @Schema(description = "角色ID")
    @NotNull(message = "角色ID不能为null")
    private Long roleId;

    /**
     * 角色名称
     */
    @TableField(value = "`name`")
    @Schema(description = "角色名称")
    @Size(max = 64, message = "角色名称最大长度要小于 64")
    @NotBlank(message = "角色名称不能为空")
    private String name;

    /**
     * 唯一编码
     */
    @TableField(value = "code")
    @Schema(description = "唯一编码")
    @Size(max = 64, message = "唯一编码最大长度要小于 64")
    @NotBlank(message = "唯一编码不能为空")
    private String code;

    /**
     * 权限范围
     */
    @TableField(value = "permission_scope_type")
    @Schema(description = "权限范围")
    private Integer permissionScopeType;

    /**
     * 权限范围数据
     */
    @TableField(value = "permission_scope", typeHandler = JacksonTypeHandler.class)
    @Schema(description = "权限范围数据")
    private PermissionScope permissionScope;

    /**
     * 是否启用
     */
    @TableField(value = "enabled")
    @Schema(description = "是否启用")
    @NotNull(message = "是否启用不能为null")
    private Boolean enabled;

    /**
     * 备注
     */
    @TableField(value = "`comment`")
    @Schema(description = "备注")
    @Size(max = 255, message = "备注最大长度要小于 255")
    private String comment;

    /**
     * 是否删除
     */
    @TableField(value = "is_delete")
    @Schema(description = "是否删除")
    @TableLogic
    private Integer isDelete;

    /**
     * 更新用户
     */
    @TableField(value = "update_user_id")
    @Schema(description = "更新用户")
    private Long updateUserId;

    /**
     * 更新时间
     */
    @TableField(value = "update_time")
    @Schema(description = "更新时间")
    private LocalDateTime updateTime;

    /**
     * 创建用户
     */
    @TableField(value = "create_user_id")
    @Schema(description = "创建用户")
    private Long createUserId;

    /**
     * 创建时间
     */
    @TableField(value = "create_time")
    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @TableField(exist = false)
    private List<Long> menuIds;

    @Serial
    private static final long serialVersionUID = 1L;
}
